<?php

require_once 'Pipes/Value/Template/CamelCapsToDatabase.php';
require_once 'PipesImpl/Filter.php';
require_once 'PipesImpl/Statement.php';

class Pipes_Statement_Basic implements PipesImpl_Statement
{
	private $_substitutions = array();
	private $_value = '';

	public function __construct($name, PipesImpl_Filter $filter) {
		$name = new Pipes_Value_Template_CamelCapsToDatabase($name);
		$this->_substitutions = $filter->getSubstitutions();
		$this->_value = "SELECT * FROM `{$name->value}s` WHERE {$filter->getCondition()}";
	}

	public function __get($key) {
		$return = null;
		switch ($key) {
			case 'substitutions' :
			case 'value' :
				$realKey = '_' . $key;
				$return = $this->$realKey;
		}

		return $return;
	}
}
